Unity3D protobuf 您所在的位置:网站首页 unity 知乎 Unity3D protobuf

Unity3D protobuf

2023-03-26 16:24| 来源: 网络整理| 查看: 265

 

1、下载protobuf-net

 

2、创建Unity工程,创建一个Plugins文件夹,将protobuf-net解压把里面得protobuf-net放到Plugins

 

3、创建一个名为mcs的文本文件,里面写上-unsafe

 

4、重启Unity

 

5、编译自动生成cs代码工具

 

protogen.exe就是刚才生成的

 

 

6、编写.proto文件

 

message.proto里写入

?12345678910message TeamCharacterOne{    required    uint64              CharacterId             = 1;    required   string             CharacterName           = 2;    required    int32               RoleId                  = 3;    required    int32               Level                   = 4;    required    int32               Ladder                  = 5;    required    int32               FightPoint              = 6;    optional    int32               QueueResult             = 7;   }

  

7、 生成.cs代码

创建一个proto.bat文件文件

里面写入

@echo off rem 查找文件 for /f "delims=" %%i in ('dir /b ".\*.proto"') do echo %%i rem 转cpp for /f "delims=" %%i in ('dir /b/a "*.proto"') do protoc -I=. --cpp_out=. %%i for /f "delims=" %%i in ('dir /b/a "*.proto"') do protogen -i:%%i -o:%%~ni.cs pause

 

8、把代码放入Unity工程



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有